from flask import Flask, request, jsonify
import requests
import json
import numpy as np
import socket
from ctypes import *
import re

app = Flask(__name__)

@app.route("/predict", methods=["POST"])
def predict():
    
    pass

class T:
    def __init__(self):
        self.ADFreq = c_double(2)
        self.pADFreq = POINTER(c_double)(self.ADFreq)
        print(self.ADFreq.value)
    
    def getADFreq(self):
        self.pADFreq.contents.value = 3.0
        print(self.ADFreq.value)
    
    def setADFreq(self):
        self.__init__()

def get_transformation_homo(rot, trans, degree=True):
    m = np.identity(4)
    m[:3, :3] = R.from_euler("XYZ", rot, degrees=degree).as_matrix()
    m[:3, 3] = trans
    return m.round(1)

if __name__ == "__main__":
    from scipy.spatial.transform import Rotation as R
    t = np.linspace(0, np.pi*2, 100)
    print(get_transformation_homo([5, 0, 4], [0, 0, 0]))
    # rot_x = 10*np.sin(t)
    # rot_y = -10*np.cos(t)
    # for t_ in range(int(10*len(t))):
    #     m = get_transformation_homo([rot_x[t_%len(t)], 0, rot_y[t_%len(t)]], [0, 0, 0])
    #     print("-------------------")
    #     print(m)
    #     print("-------------------")